package br.edu.utfpr.backuptools.BackupTools.view.telas.principal.tabela;

import java.awt.Component;

import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;

import br.edu.utfpr.backuptools.BackupTools.model.pojo.Backup;
import br.edu.utfpr.backuptools.BackupTools.view.telas.principal.JanelaPrincipal;

public class BackupCellEditor extends AbstractCellEditor implements TableCellEditor{
	BackupCellComponent backupComponent;
	JanelaPrincipal janelaPrincipal;
	
	public BackupCellEditor(JanelaPrincipal janelaPrincipal){
		backupComponent = new BackupCellComponent(janelaPrincipal);
		this.janelaPrincipal = janelaPrincipal;
	}
	
	@Override
	public Object getCellEditorValue() {
		return null;
	}

	@Override
	public Component getTableCellEditorComponent(JTable table, Object value,
			boolean isSelected, int row, int column) {
		
		Backup backup = (Backup)value;
		janelaPrincipal.updateSelecionado(backup);
	    backupComponent.updateData(backup, true, table);
	    return backupComponent;
	}

}
